import 'package:amway_superapp_creator_plugin/models/create_user_info_model.dart';

import 'package:flutter/material.dart';
// import 'package:flutter_inappwebview/flutter_inappwebview.dart';


class CircleDetailData {
  String id;
  String ada = "";
  String amwayId;
  String auditStatus;
  String autoPublish = "YES";
  String createTime;
  String description;
  int descriptionVerify = 0; //正文审核状态
  List<DisplayAudits> displayAudits;
  List<ImagesBean> medias = [];
  String officialFlag = "";
  String officialPgcId;
  List<Products> products = [];
  String publishStatus = "";
  String title;
  int titleVerify = 0; //标题审核状态
  String ugcId;

  CircleDetailData(
      {this.ada = "ada",
      this.amwayId,
      this.titleVerify = 0,
      this.descriptionVerify = 0,
      this.auditStatus,
      this.id,
      this.autoPublish = "YES",
      this.createTime,
      this.description,
      this.displayAudits,
      this.medias,
      this.officialFlag = "",
      this.officialPgcId,
      this.products,
      this.publishStatus,
      this.title,
      this.ugcId});

  CircleDetailData.fromJson(Map<String, dynamic> json) {
    ada = json['ada'];
    id = json['id'].toString();
    amwayId = json['amwayId'];
    auditStatus = json['auditStatus'];
    autoPublish = json['autoPublish'];
    createTime = json['createTime'].toString();
    description = json['description'];
    if (json['displayAudits'] != null) {
      displayAudits = new List<DisplayAudits>();
      json['displayAudits'].forEach((v) {
        displayAudits.add(new DisplayAudits.fromJson(v));
      });
    }
    if (json['medias'] != null) {
      medias = new List<ImagesBean>();
      json['medias'].forEach((v) {
        medias.add(new ImagesBean.fromJson(v));
      });
    }
    officialFlag = json['officialFlag'] ?? 'NO';
    officialPgcId = json['officialPgcId'];
    if (json['products'] != null) {
      products = new List<Products>();
      json['products'].forEach((v) {
        products.add(new Products.fromJson(v));
      });
    }
    publishStatus = json['publishStatus'] ?? 'UN_PUBLISH';
    title = json['title'];
    ugcId = json['ugcId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ada'] = this.ada;
    data['amwayId'] = this.amwayId;
    data['auditStatus'] = this.auditStatus;
    data['autoPublish'] = this.autoPublish;
    data['createTime'] = this.createTime;
    data['description'] = this.description;
    if (this.displayAudits != null) {
      data['displayAudits'] =
          this.displayAudits.map((v) => v.toJson()).toList();
    }
    if (this.medias != null) {
      data['medias'] = this.medias.map((v) => v.toJson()).toList();
    }
    data['officialFlag'] = this.officialFlag;
    data['officialPgcId'] = this.officialPgcId;
    if (this.products != null) {
      data['products'] = this.products.map((v) => v.toJson()).toList();
    }
    data['publishStatus'] = this.publishStatus;
    data['title'] = this.title;
    data['ugcId'] = this.ugcId;
    return data;
  }

  @override
  bool operator ==(Object other) {
    if (other is CircleDetailData) {
      if (this.medias.length == other.medias.length) {
        for (int i = 0; i < this.medias.length; i++) {
          for (int j = 0; j < other.medias.length; j++) {
            if (i == j) {
              if (this.medias[i].data != other.medias[j].data) {
                return false;
              }
            } else {
              continue;
            }
          }
        }
      } else {
        return false;
      }
      if (this.products.length == other.products.length) {
        for (int i = 0; i < this.products.length; i++) {
          for (int j = 0; j < other.products.length; j++) {
            if (i == j) {
              if (this.products[i].skuCode != other.products[j].skuCode) {
                return false;
              }
            } else {
              continue;
            }
          }
        }
      } else {
        return false;
      }
      if (this.title == other.title && this.description == other.description) {
        return true;
      } else {
        return false;
      }
    }
  }
}

class DisplayAudits {
  String data;
  String propertyNameTip;
  String resourceType;
  String status;

  DisplayAudits(
      {this.data, this.propertyNameTip, this.resourceType, this.status});

  DisplayAudits.fromJson(Map<String, dynamic> json) {
    data = json['data'];
    propertyNameTip = json['propertyNameTip'];
    resourceType = json['resourceType'];
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['data'] = this.data;
    data['propertyNameTip'] = this.propertyNameTip;
    data['resourceType'] = this.resourceType;
    data['status'] = this.status;
    return data;
  }
}

class Medias {
  String data;
  String dataType;
  String officialFlag;
  int imageVerify = 0;

  Medias({this.data, this.dataType, this.officialFlag, this.imageVerify = 0});

  Medias.fromJson(Map<String, dynamic> json) {
    data = json['data'];
    dataType = json['dataType'];
    officialFlag = json['officialFlag'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['data'] = this.data;
    data['dataType'] = this.dataType;
    data['officialFlag'] = this.officialFlag;
    return data;
  }
}

class Products {
  String approvalStatus;
  String itemSku;
  bool orderable;
  String pdpVideoUrl;
  String picture;
  PriceData priceData;
  String productCode;
  String productName;
  String skuCode;
  String skuName;
  String skuUnitName;
  String specDescription;
  String specUnitName;
  String unitName;

  Products(
      {this.approvalStatus,
      this.itemSku,
      this.orderable,
      this.pdpVideoUrl,
      this.picture,
      this.priceData,
      this.productCode,
      this.productName,
      this.skuCode,
      this.skuName,
      this.skuUnitName,
      this.specDescription,
      this.specUnitName,
      this.unitName});

  Products.fromJson(Map<String, dynamic> json) {
    approvalStatus = json['approvalStatus'];
    itemSku = json['itemSku'];
    orderable = json['orderable'];
    pdpVideoUrl = json['pdpVideoUrl'];
    picture = json['picture'];
    priceData = json['priceData'] != null
        ? new PriceData.fromJson(json['priceData'])
        : null;
    productCode = json['productCode'];
    productName = json['productName'];
    skuCode = json['skuCode'];
    skuName = json['skuName'];
    skuUnitName = json['skuUnitName'];
    specDescription = json['specDescription'];
    specUnitName = json['specUnitName'];
    unitName = json['unitName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['approvalStatus'] = this.approvalStatus;
    data['itemSku'] = this.itemSku;
    data['orderable'] = this.orderable;
    data['pdpVideoUrl'] = this.pdpVideoUrl;
    data['picture'] = this.picture;
    if (this.priceData != null) {
      data['priceData'] = this.priceData.toJson();
    }
    data['productCode'] = this.productCode;
    data['productName'] = this.productName;
    data['skuCode'] = this.skuCode;
    data['skuName'] = this.skuName;
    data['skuUnitName'] = this.skuUnitName;
    data['specDescription'] = this.specDescription;
    data['specUnitName'] = this.specUnitName;
    data['unitName'] = this.unitName;
    return data;
  }
}

class PriceData {
  String currency;
  double price;
  String saleStatus;
  String skuCode;

  PriceData({this.currency, this.price, this.saleStatus, this.skuCode});

  PriceData.fromJson(Map<String, dynamic> json) {
    currency = json['currency'];
    price = json['price'];
    saleStatus = json['saleStatus'];
    skuCode = json['skuCode'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['currency'] = this.currency;
    data['price'] = this.price;
    data['saleStatus'] = this.saleStatus;
    data['skuCode'] = this.skuCode;
    return data;
  }
}
